<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 在数组原型上添加 myFilter 方法
        Array.prototype.myFilter = function (callback) {
            let arr = []
            for (let i = 0; i < this.length; i++) {
             
                 callback(this[i],i,this) && arr.push(this[i])
            }
            return arr
        }

        let arr = [7,8,9,6,8]
 
       const arr2 = arr.myFilter((item,index,arr) => {
            return item == 8
        })
        console.log(arr2);
    </script>
</body>

</html>